# comun self hosted implementation: general library
# module prefix: g
#
# This module contains resources that will generally be needed by any other
# program making use of this comun implementation.
#
# NOTES:
#
# === ABBREVIATIONS ===
#
# - addr: address
# - arg: argument
# - BC: bytecode
# - com: compiler
# - const: constant
# - func: function
# - IC: immediate constant
# - instr(s): instruction(s)
# - interp: interpreter
# - mem: memory
# - num: number
# - PT: ptr table
# - ptr: pointer
# - ST: stack top
# - succ: success
# - TE: type environment
# - tmp: temporary
# - val: value
# - var: variable
#
# === NAMING ===
#
# - each library file starts with "cmn_" prefix
# - each public symbol the library starts with "CMN_" prefix
# - each private (not meant for external use) starts with "_CMN_" prefix
# - after CMN_/_CMN_/ a file (module) specific prefix follows
#
# === FUNCTION DOCUMENTATION ===
#
# Arguments are documented on line staring with "arg: ". Arguments outside TE
# 0 will be prefixed with their TE (1, 2 or 3), in order from lowest stack addr
# to stack top, i.e. e.g. "paramX 2paramY paramW" means func takes 2
# parameters in TE 0 (paramX below paramW) and 1 in TE 16. Func return
#
# Return vals are documented on line starting with "ret: ". The notation is
# same as with args.

# temporary helper variables and ptrs, WATCH OUT: their val may change
# after calling a func, if you need them to retain val, check if the
# func you are calling modifies given variable. Minimize relying on this.

CMN_gLANG_V_STR: "0.95" . # version of implemented language

~_CMN_gV1      # tmp var
~_CMN_gP1:0    # tmp ptr

~16
  ~_CMN_g2V1   # tmp var in TE 16
  ~_CMN_g2P1:0 # tmp ptr in TE 16
  ~_CMN_g2P2:0 # tmp ptr 2 in TE 16
~0

~32
  ~_CMN_g3V1   # tmp var in TE 32
  ~_CMN_g3P1:0 # tmp ptr in TE 32
  ~_CMN_g3P2:0 # tmp ptr 2 in TE 32
~0

CMN_gMax:  <' ? >< . ^ .
CMN_gMaxS: <<' ? >< . ^ .
